package net.coding.bamboo.wex.mq.handler;

import com.weihui.mq.handler.notify.AbstractNotifyMessageHandler;
import net.coding.bamboo.wex.mq.model.InputMessage;
import net.coding.bamboo.wex.mq.processor.MessageProcessor;
import org.springframework.beans.factory.annotation.Autowired;

/**
 * @author : zenghua
 * @version : v0.1 SendMessageHandler.java
 * @since : 2017/7/13 19:45
 */
public class SendMessageHandler extends AbstractNotifyMessageHandler {
    @Autowired
    private MessageProcessor messageProcessor;

    /**
     *
     *
     * 执行入口AbstractMessageListenerContainer.initialize()初始化DefaultMessageListener（实现MessageListener），
     * DefaultMessageListener.onMessage，里面messageHandler.handle(request);
     *
     * @param request 参考AbstractHandler.handle(),为DefaultNotifyRequest的content
     * @throws Exception
     */
    @Override
    public void handleMessage(Object request) throws Exception {
        InputMessage inputMessage = (InputMessage)request;
        messageProcessor.process(inputMessage);
    }

    public void setMessageProcessor(MessageProcessor messageProcessor) {
        this.messageProcessor = messageProcessor;
    }
}
